//
//  BCVideoListVC.m
//  BananaChat
//
//  Created by 于洪东 on 2019/11/1.
//  Copyright © 2019 香蕉. All rights reserved.
//

#import "BCVideoListVC.h"
#import "BCVideoListCollectionCell.h"

@interface BCVideoListVC ()<UICollectionViewDelegate,UICollectionViewDataSource>

@property (nonatomic,strong) UICollectionView *listView;
@property (nonatomic,strong) NSMutableArray *dataArray;

@end

@implementation BCVideoListVC
#pragma mark - ♻️life cycle
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self hideBackButton];
    [self setupUI];
}


#pragma mark - 🔄overwrite

#pragma mark - 🚪public

#pragma mark - 🍐delegate

#pragma mark -- UICollectionViewDelegate
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    DEF_DEBUG(@"%s",__func__);
}


#pragma mark -- UICollectionViewDataSource

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    //    return self.dataArray.count;
    return 30;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    BCVideoListCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"BCVideoListCollectionCell" forIndexPath:indexPath];
    return cell;
}

#pragma mark -- UICollectionViewDelegateFlowLayout
/** 每个cell的尺寸 */
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    CGFloat width = (SCREEN_WIDTH - 30) / 2;
    CGFloat height = width * 4 / 3;
    return CGSizeMake(width,height);
}

/** 每个cell的横向间距 */
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
    return 10;
}

/** 每个cell的纵向间距 */
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
    return 10;
}

/** section的margin*/
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(0, 10, 10, 10);
}

#pragma mark - ☎️notification

#pragma mark - 🎬event response

#pragma mark - 🔒private

#pragma mark - 🌲setupUI
-(void)setupUI{
    
    self.listView.contentInsetAdjustmentBehavior = YES;
    [self.view addSubview:self.listView];
    
    [self.listView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view);
    }];
    
    [self.listView registerClass:[BCVideoListCollectionCell class] forCellWithReuseIdentifier:@"BCVideoListCollectionCell"];
    
}

#pragma mark - ☸getter and setter

-(UICollectionView *)listView{
    if (_listView == nil) {
        UICollectionViewFlowLayout *flowlayout = [[UICollectionViewFlowLayout alloc]init];
        [flowlayout setScrollDirection:UICollectionViewScrollDirectionVertical];
        _listView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:flowlayout];
        _listView.delegate = self;
        _listView.dataSource = self;
        _listView.backgroundColor = NTBackGroundColor;
    }
    return _listView;
}


-(NSMutableArray *)dataArray{
    if (_dataArray == nil) {
        _dataArray = [NSMutableArray array];
    }
    return _dataArray;
}


@end
